<template>
    
  <div class="home">

    <el-container style="height: 500px; border: 1px solid #eee">

  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    <el-menu
    unique-opened 
     router 
     :default-active="this.$router.path" 
     :default-openeds="['0']"
     >

      <el-submenu :index="index+''" v-for="(item,index) in map" :key="index" >
        <template slot="title"><i class="el-icon-message">{{item.menuKey.name}}</i></template>
        <el-menu-item-group v-for="(item2,index2) in item.listMenu" :key="index2">
          <!-- <template slot="title">分组一</template> -->
          <!-- <el-menu-item index="/home/EmpView">ddd</el-menu-item>-->
          <!-- <el-menu-item index="/home/hello">djjj</el-menu-item>   -->
           <el-menu-item :index="item2.linkurl">{{item2.name}}</el-menu-item> 
        </el-menu-item-group>
      </el-submenu>

    </el-menu>
  </el-aside>
  
  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <el-dropdown>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>查看</el-dropdown-item>
          <el-dropdown-item>新增</el-dropdown-item>
          <el-dropdown-item ><samp @click="deleteUser()">删除</samp></el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span>{{username}}</span>
    </el-header>
    
    <el-main>
      
  <router-view></router-view>
    </el-main>
  </el-container>
</el-container>

  </div>
</template>

<script>

  export default {
    data() {
      return {
        map:[]
      }
    },
    created(){
      this.axios.post("/api/menu.action").then(data=>{

this.map=data.data;
console.log(this.map)

})
      this.username=localStorage.getItem("name");
              
    },
    methods:{
      show(){
   

      },
      deleteUser(){
        alert("退出")
  
        localStorage.removeItem("name");
        this.$router.push({path:"/login"})
      }
    }
  };
</script>

<style scoped>

.el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
</style>
